package org.fuys.etp.repo.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 配置改变历史
 * @TableName etp_config_history
 */
@TableName(value ="etp_config_history")
@Data
public class EtpConfigHistory implements Serializable {
    /**
     * 历史记录id 主键自增
     */
    @TableId(type = IdType.AUTO)
    private Long historyId;

    /**
     * 线程池类型
     */
    private String poolType;

    /**
     * 线程池名称
     */
    private String poolName;

    /**
     * 更改前配置版本
     */
    private Integer previousConfigVersion;

    /**
     * 更改后配置版本
     */
    private Integer currentConfigVersion;

    /**
     * 配置更改时间
     */
    private Date changeTime;

    /**
     * 更改类型 可能是人为或自检
     */
    private Integer changeType;

    /**
     * 更新的用户ID 如果是自检 则不存在ID
     */
    private Long changeUserId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        EtpConfigHistory other = (EtpConfigHistory) that;
        return (this.getHistoryId() == null ? other.getHistoryId() == null : this.getHistoryId().equals(other.getHistoryId()))
            && (this.getPoolType() == null ? other.getPoolType() == null : this.getPoolType().equals(other.getPoolType()))
            && (this.getPoolName() == null ? other.getPoolName() == null : this.getPoolName().equals(other.getPoolName()))
            && (this.getPreviousConfigVersion() == null ? other.getPreviousConfigVersion() == null : this.getPreviousConfigVersion().equals(other.getPreviousConfigVersion()))
            && (this.getCurrentConfigVersion() == null ? other.getCurrentConfigVersion() == null : this.getCurrentConfigVersion().equals(other.getCurrentConfigVersion()))
            && (this.getChangeTime() == null ? other.getChangeTime() == null : this.getChangeTime().equals(other.getChangeTime()))
            && (this.getChangeType() == null ? other.getChangeType() == null : this.getChangeType().equals(other.getChangeType()))
            && (this.getChangeUserId() == null ? other.getChangeUserId() == null : this.getChangeUserId().equals(other.getChangeUserId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getHistoryId() == null) ? 0 : getHistoryId().hashCode());
        result = prime * result + ((getPoolType() == null) ? 0 : getPoolType().hashCode());
        result = prime * result + ((getPoolName() == null) ? 0 : getPoolName().hashCode());
        result = prime * result + ((getPreviousConfigVersion() == null) ? 0 : getPreviousConfigVersion().hashCode());
        result = prime * result + ((getCurrentConfigVersion() == null) ? 0 : getCurrentConfigVersion().hashCode());
        result = prime * result + ((getChangeTime() == null) ? 0 : getChangeTime().hashCode());
        result = prime * result + ((getChangeType() == null) ? 0 : getChangeType().hashCode());
        result = prime * result + ((getChangeUserId() == null) ? 0 : getChangeUserId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", historyId=").append(historyId);
        sb.append(", poolType=").append(poolType);
        sb.append(", poolName=").append(poolName);
        sb.append(", previousConfigVersion=").append(previousConfigVersion);
        sb.append(", currentConfigVersion=").append(currentConfigVersion);
        sb.append(", changeTime=").append(changeTime);
        sb.append(", changeType=").append(changeType);
        sb.append(", changeUserId=").append(changeUserId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}